package com.pkuse.bjousystem;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;

public class MyAuthenticationToken extends UsernamePasswordAuthenticationToken {

    private AuthEntity.AuthType type;

    public MyAuthenticationToken(Object principal, Object credentials, String type) {
        super(principal, credentials);
        this.type = AuthEntity.AuthType.fromString(type);
        super.setAuthenticated(false);
    }

    public MyAuthenticationToken(Object principal, Object credentials, String type,
                                     Collection<? extends GrantedAuthority> authorities) {
        super(principal, credentials, authorities);
        this.type = AuthEntity.AuthType.fromString(type);
        super.setAuthenticated(true); // must use super, as we override
    }

    public AuthEntity.AuthType getAuthType() {
        return this.type;
    }
}